<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>设备任务管理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0"> 
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<jsp:include page="../resource.jsp"></jsp:include>
	<script type="text/javascript">
	$(document).ready(function() {
		var h = '85%';
 		if($.browser.msie && ($.browser.version == 8.0 || $.browser.version == 9.0)){
 	    	 h = $(self.parent.parent.frames['mainFrame']).height()-87; 
 	    }
        $('#serverJobGrid').omGrid({
        	dataSource : 'paramServerJob!findAll.do',
            height : h,
            limit : 20,
            showIndex : true,
            colModel : [ 
                         {header : '设备名称', name : 'deviceName', width : 100, align : 'center'},
                         {header : 'GUID', name : 'guid', width : 120, align : 'center'},
                         {header : '任务执行方式', name : 'jobMode', width : 120, align : 'center' ,renderer : modelRenderer},
                         {header : '任务状态', name : 'jobStatus', width : 100, align : 'center',renderer : statusRenderer},
                         {header : '创建人', name : 'userName', width : 90, align : 'center'},
                         {header : '创建时间', name : 'createDatetime', width : 140, align : 'center'},
                         {header : '开始时间', name : 'startTime', width : 140, align : 'center'},
                         {header : '任务结束时间', name : 'finishDatetime', width : 140, align : 'center'}
                         ]
        });
        
    $('#jobStatus').omCombo({
    	dataSource : 'upgrade!findJobStatus.do',
        onValueChange : function(target, newValue, oldValue) {
            $('#jobStatusId').val(newValue);
        }
    });
    $('#jobMode').omCombo({
    	dataSource : 'upgrade!findJobMode.do',
        onValueChange : function(target, newValue, oldValue) {
        	 $('#jobModeId').val(newValue);
        }
    });
    
	function modelRenderer(v)
	{
		if(v == null) return "";
		return v.name;
	}
	function statusRenderer(v)
	{
		if(v == null) return "";
		return v.name;
	}
	$("#serverJobSerach").click(function() {
		var deviceId = $("#jobDeviceGuid").val();
		var queryTime = $("#jobQueryTime").val();
        $("#serverJobGrid").omGrid('setData','paramServerJob!findAll.do?deviceId='+deviceId+'&queryTime='+queryTime);
        return false;//返回false,阻止浏览器默认行为
    });
	$("#serverJobResetBtn").click(function() {
		$('#jobDeviceName').val('点击右侧菜单');
		$('#jobDeviceGuid').val('');
	});
	 	var tabId = self.parent.parent.frames['mainFrame'].$('#tabs').omTabs('getActivated');
		var s = "<script>function function_"+tabId+"(nodeData){$('#jobDeviceName').val(nodeData.text);"+
		"$('#jobDeviceGuid').val(nodeData.id);}<\/script>";
		$("#serverJobGrid").after(s);
    });
	</script>  
  </head>
  
  <body>
    <div class="select_table">
    	<table   cellpadding="0" cellspacing="0" class="layout"  border="0">
	          <tr>
	            <td width="11%" align="right">设备：</td>
	            <td width="9%">
	            	<input name="jobDeviceName" id="jobDeviceName" type="text" readonly="readonly" value="点击右侧菜单选择" size="16"/>
	            	<input name="jobDeviceGuid" id="jobDeviceGuid" type="hidden"/>
	            </td>
                 <td width="5%" align="right">时间：</td>
	            <td width="8%"><select name="jobQueryTime" id="jobQueryTime">
                 	<option value="9">全部</option>
                 	<option value="0" selected="selected">一周内</option>
                 	<option value="1" >一周前</option>
                 </select></td>
	            <td align="left">
	            	<button class="button_u" id="serverJobSerach" onmousemove="this.className='button_f'" onmousedown="this.className='button_d'" onmouseout="this.className='button_u'">查询</button>
	            	<button class="button_u" id="serverJobResetBtn" onmousemove="this.className='button_f'" onmousedown="this.className='button_d'" onmouseout="this.className='button_u'">重置</button>
	            </td>
	          </tr>
	    </table>
	</div>
    <table id="serverJobGrid"></table>
  </body>
</html>
